'巫师敌人，和基础敌人没什么不同'

extends CharacterBody2D

@onready var health_component:HealthComponent = $HealthComponent
@onready var animation = $AnimationPlayer
@onready var linear_movement_component: Node = $LinearMovementComponent

var damage = 2#自身伤害


func _ready() -> void:
	$HealthComponent.died.connect(on_died)
	$HurtboxComponent.hurt.connect(on_hurt)
	pass

#向玩家移动
func _process(_delta: float) -> void:
	var player = get_tree().get_first_node_in_group("player")
	if player == null:
		return
	linear_movement_component.move(self,player.global_position)
	if self.velocity.x || self.velocity.y:
		animation.play("walk")
	else:
		animation.play("RESET")
	if self.velocity.x < 0:
		$Sprite2D.flip_h = true
	else:
		$Sprite2D.flip_h = false
	pass

#死亡时自动销毁
func on_died() -> void:
	self.queue_free.call_deferred()
	pass

#受到伤害时发出声音
func on_hurt() -> void:
	$RanAudComponent.play_random()
	pass
